package vn.candyapp.qlct.utils;

import java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy;

import vn.candyapp.qlct.R;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class DialogUtils {
	
	public static void showMessage(Context context, String message) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setMessage(message)
		.setNegativeButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		})
		.create()
		.show();
		
		
	}
	
	
	public static void showConfirm(Context context, String message, final IDialogConfirmListener listener) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setMessage(message)
		.setNegativeButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				if (listener != null)
					listener.onOk();
				dialog.dismiss();
			}
		}).setPositiveButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				if (listener != null) 
					listener.onCancel();
				dialog.dismiss();
			}
		})
		.create()
		.show();
	}
	
	public interface IDialogConfirmListener {
		void onOk();
		void onCancel();
	}
	
}
